using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using CSP.Model.CSP;

namespace CSP.DataAccess.Mapping
{
    public class UserCreditMap : EntityTypeConfiguration<UserCredit>
    {
        public UserCreditMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.username)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.LastModified)
                .IsFixedLength()
                .HasMaxLength(8)
                .IsRowVersion();

            // Table & Column Mappings
            this.ToTable("UserCredit");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.username).HasColumnName("username");
            this.Property(t => t.ServiceCredit).HasColumnName("ServiceCredit");
            this.Property(t => t.ConsumeCredit).HasColumnName("ConsumeCredit");
            this.Property(t => t.ServiceAbility).HasColumnName("ServiceAbility");
            this.Property(t => t.ServiceAttitude).HasColumnName("ServiceAttitude");
            this.Property(t => t.CreditCount).HasColumnName("CreditCount");
            this.Property(t => t.LastModified).HasColumnName("LastModified");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
        }
    }
}
